import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import locale from 'element-ui/lib/locale/lang/en' // lang i18n
import {  Message } from 'element-ui'
import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
require('echarts/lib/component/legend')
import '@/icons' // icon
import '@/permission' // permission control

// 引入 echarts 核心模块，核心模块提供了 echarts 使用必须要的接口。
import * as echarts from 'echarts/core';
// 引入柱状图图表，图表后缀都为 Chart
import { BarChart ,RadarChart ,LineChart } from 'echarts/charts';
// 引入提示框，标题，直角坐标系，数据集，内置数据转换器组件，组件后缀都为 Component
// import { LegendComponent } from 'echarts/components';
// echarts.use([LegendComponent]);
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  
} from 'echarts/components';
// 标签自动布局，全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features';
// 引入 Canvas 渲染器，注意引入 CanvasRenderer 或者 SVGRenderer 是必须的一步
import { CanvasRenderer } from 'echarts/renderers';
import  permiss  from '@/directive/permission'
import VueClipboard from 'vue-clipboard2'
// 注册必须的组件
echarts.use([
  TitleComponent,
  LineChart,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  BarChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
  RadarChart
]);





/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
if (process.env.NODE_ENV === 'production') {
  const { mockXHR } = require('../mock')
  mockXHR()
}
  Vue.prototype.$echarts = echarts
// set ElementUI lang to EN
  Vue.filter('mytime',function(value){
    //  monnent
      return  value.substring(0,10)
  })
  import  xsform from '@/components/form/xsform'
  Vue.component('xsform',xsform)
  Vue.directive('permission',permiss)
  // Vue.filter('myNum',function(num){
  //   var arr1 = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']

  //   var arr2 = ['', '十', '百', '千', '万', '十', '百', '千', '亿', '十', '百', '千', '万', '十', '百', '千', '亿']

  //   if (!num || isNaN(num)) return '零'

  //   var english = num.toString().split('')

  //   var result = ''

  //   for (var i = 0; i < english.length; i++) {

  //     var des_i = english.length - 1 - i// 倒序排列设值

  //     result = arr2[i] + result

  //     var arr1_index = english[des_i]

  //     result = arr1[arr1_index] + result

  //   }

  //   result = result.replace(/零(千|百|十)/g, '零').replace(/十零/g, '十') // 将【零千、零百】换成【零】 【十零】换成【十】

  //   result = result.replace(/零+/g, '零') // 合并中间多个零为一个零

  //   result = result.replace(/零亿/g, '亿').replace(/零万/g, '万') // 将【零亿】换成【亿】【零万】换成【万】

  //   result = result.replace(/亿万/g, '亿') // 将【亿万】换成【亿】

  //   result = result.replace(/零+$/, '') // 移除末尾的零

  //   // 将【一十】换成【十】

  //   result = result.replace(/^一十/g, '十')

  //   return result

  // })
  Vue.use(VueClipboard)
Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
console.log("刷新了");
Vue.config.productionTip = false
Vue.prototype.$msg = Message
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
